import api from '../../server/api';

const state = {
    swarp:[],
    stitle:[],
    sclass:[],
    spromotion:[],
    slikes:[]

}

const getters = {}

const actions = {
    loadHomeData({ commit }){
        api.loadDataByPids({
            appPlat: "m",
            pids: "51822,106930,51833,51836"
        }).then(({ data })=>{
            commit("setSwarp",data[51822].list);
            commit("setStitle",data[106930].list);
            commit("setSpromotion",data[51833].list);
            commit("setSclass",data[51836].list);

        });
        api.loadDataByLike({
            pid:"9750",
            sort:"pop",
            cKey:46
        }).then(({result})=>{
            commit("setSlikes",result.wall.docs);
        })
    }    
}

const mutations = {
    setSwarp(state,data){
        state.swarp = data
    },
    setStitle(state,data){
        state.stitle = data

    },
    setSclass(state,data){
        state.sclass = data

    },
    setSpromotion(state,data){
        state.spromotion = data
    },
    setSlikes(state,data){
        state.slikes = data

    }
}

export default {
    state,
    actions,
    mutations,
    getters
}
